package com.clive.xxweb.controller;

import com.clive.xxweb.bean.User;
import com.clive.xxweb.service.UserService;
import com.clive.xxweb.vo.DishResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/login")
    public DishResult login(@RequestBody @Valid User user){
      User u = userService.findUserAndPass(user);

        return DishResult.ok().data("user",u);
    }
}
